Next | Prev | Up | Top | Contents | Index

Entry Point strategy()

A block device driver does not directly support user process calls. Instead, it provides services to a filesystem such as EFS, or to the memory paging subsystem of IRIX. These subsystems call the pfxstrategy() entry point to read data in whole blocks.

Calls to pfxstrategy() are not directly related in time to system functions called by a user process. For example, a filesystem may buffer many blocks of data in memory, so that the user process may execute dozens or hundreds of write() calls without causing an entry to the device driver. When the user function closes the file or calls fsync()--or when for unrelated reasons the filesystem needs to free some buffers--the filesystem calls pfxstrategy() to write numerous blocks of data.

In a driver that supports the character interface as well, the pfxstrategy() entry can be called indirectly from the pfxread(), pfxwrite() and pfxioctl() entries, as described under "Calling Entry Point strategy() From Entry Point read() or write()".

The prototype of the pfxstrategy() entry point is

int pfxstrategy(struct buf *bp);

The argument is the address of a buf_t structure, which gives the strategy routine the information it needs to perform the I/O:

For more on the contents of the buf_t structure, see "Structure buf_t" and the buf(D4) reference page.

The driver uses the information in the buf_t to validate the data transfer and programs the device to start the transfer. Then it stores the address of the buf_t where the interrupt handler can find it (see "Entry Point intr()") and calls biowait() to wait for the operation to complete. For the next step, see "Completing Block I/O" (see also the biowait(D3) reference page).


Next | Prev | Up | Top | Contents | Index